<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改仓库信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-warehouse-edit" th:object="${warehouse}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">仓库类型：</label>
                <div class="col-sm-8">
                    <select name="type" id="warehouseType" class="form-control m-b"
                            th:with="type=${@dict.getType('warehouse_type')}"
                            onchange="checkType()">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">关联的总仓：</label>
                <div class="col-sm-8">
                    <select id="parentCode" name="parentCode" class="form-control select2-multiple"
                            data-first-title="选择总仓" data-required="true">
                        <option th:each="model:${list}" th:value="${model.warehouseCode}"
                                th:text="${model.warehouseName}" th:field="*{parentCode}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">仓库名称：</label>
                <div class="col-sm-8">
                    <input name="warehouseName" th:field="*{warehouseName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">仓库编码：</label>
                <div class="col-sm-8">
                    <input name="warehouseCode" th:field="*{warehouseCode}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">省：</label>
                <div class="col-sm-8">
                    <input name="provinceId" id="provinceId" th:field="*{provinceId}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">市：</label>
                <div class="col-sm-8">
                    <input name="cityId" id="cityId" th:field="*{cityId}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">区：</label>
                <div class="col-sm-8">
                    <input name="areaId" id="areaId" th:field="*{areaId}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">仓库地址</label>
                <div class="col-sm-8">
                    <input name="address"  th:field="*{address}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">经度：</label>
                <div class="col-sm-8">
                    <input name="longitude" th:field="*{longitude}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">纬度：</label>
                <div class="col-sm-8">
                    <input name="latitude" th:field="*{latitude}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">联系人姓名：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">联系人电话：</label>
                <div class="col-sm-8">
                    <input name="phone" th:field="*{phone}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">总库位数：</label>
                <div class="col-sm-8">
                    <input name="totalStorageCount" th:field="*{totalStorageCount}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">仓数：</label>
                <div class="col-sm-8">
                    <input name="quantity" th:field="*{quantity}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">列数：</label>
                <div class="col-sm-8">
                    <input name="columnQuantity" th:field="*{columnQuantity}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">行数：</label>
                <div class="col-sm-8">
                    <input name="rowQuantity" th:field="*{rowQuantity}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">所属区域：</label>
                <div class="col-sm-8">
                    <input name="areaCode" th:field="*{areaCode}" class="form-control" type="text" disabled>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">所属区域的主题：</label>
                <div class="col-sm-8">
                    <input name="topicInfo" th:field="*{topicInfo}" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        $(function () {
            checkType();
        });
        var prefix = ctx + "system/warehouse";
        $("#form-warehouse-edit").validate({
            rules: {
                phone: {
                    isPhone: true
                },
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-warehouse-edit').serialize());
            }
        }

        function checkType() {
            const value = $("#warehouseType").val();
            if (value == "0") {
                $("#parentCode").val("");
                $("#parentCode").attr("disabled", "disabled");
            } else {
                $("#parentCode").removeAttr("disabled");
                $("#parentCode option:first").prop("selected", 'selected');
                $("#parentCode").val($("#parentCode option:first").val());
            }
            $("#warehouseType").attr("disabled", "disabled");
        }
    </script>
</body>
</html>